<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    .box {
      position: relative;
      width: 800px;
      height: 600px;
      margin: 50px auto;
      background-color: #ccc;
    }
    .child {
      width: 400px;
      height: 200px;
      background-color: pink;
      /* 定位 + 转换 */
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  </style>
  <body>
    <div class="box">
      <div class="child"></div>
    </div>
  </body>
</html>
